<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>同比环比</title>
    <link href="../../layui/css/layui.css" rel="stylesheet" type="text/css">
    <script src="../../layui/layui.js"></script>
    <link href="../../css/style.css" rel="stylesheet" type="text/css">
    <script src="../../js/jquery-1.8.3.js"></script>
    <script src="../../js/util.js"></script>
    <script>
        function getdate(number) {
            var myDate = new Date();
            //当前年份
            var nowyear = myDate.getFullYear();
            //当前月份
            var nowmonth = myDate.getMonth()+1;
            if (number==365) {
                var date = nowyear-1 + "." + nowmonth;
            } else {
                var month = nowmonth - number;
                var year = month > 0 ? nowyear : nowyear - 1;
                month = month > 0 ? month : month + 12;
                var date = year + "." + month;
            }
            return date;
        }

        function select() {
            var way = document.getElementsByName("way");
            for (var i = 0; i < way.length; i++) {
                if (way[i].checked) {
                    var url = way[i].value + ".html";
                    location.href = url;
                }
            }
        }

        layui.use(['table','jquery','element','layer'], function () {
            var table = layui.table;
            var $ = layui.$;
            var layer=layui.layer;
            $("#download").on('click', function () {
                location.href = '/smsSendCompare/export?flag=city';
            });
            var tableData={
                elem: "#table",//表格id
                id: "modelReload", //id
                url: '/smsSendCompare/find',
                totalRow: true,
                method: 'post',
                cellMinWidth: 100,
                request: {
                    pageName: 'page',
                    limitName: 'limit'
                },
                response: {
                    statusName: 'code',
                    statusCode: 0,
                    msgName: 'msg',
                    countName: 'count',
                    dataName: 'data'
                },
                where:{flag:'city'},
                page: true,
                count: "count",
                limit: 10,
                limits: [10, 20, 30, 40, 50],
                layout: ['prev', 'page', 'next'],
                prev: "上一页",
                next: "下一页",
                cols: [[ //表头
                    {field: 'cityName', title: '地市', totalRowText: '合计'}
                    , {field: 'nowNumber', title: getdate(0), totalRow: true}
                    , {field: 'lastMonthNumber', title: getdate(1), totalRow: true}
                    , {field: 'lastYearMonthNumber', title:getdate(365), totalRow: true}
                    , {field: 'compareYearLastMonthNumber', title: '同比增长率', totalRow: true}
                    , {field: 'compareLastMonthNumber', title: '环比增长率', totalRow: true}
                ]], done: function (res) {
                    layer.close(index);
                }
            };
            var index = layer.load(1, {
                shade: [0.1,'#fff'] //0.1透明度的白色背景
            });
            table.render(tableData);

            //身份识别
//            $(document).ready(function () {
//                $.ajax({
//                    type: 'post',
//                    async: false,
//                    url: '/util/findUser',
//                    success: function (json) {
//                        if (json.duty == 2) {
//                            layer.msg("项目管理员只能查看项目数据，请选择按项目方式查询");
//                            $("#download").attr("disabled", true);
//                        }else {
//                            table.render(tableData);
//                        }
//                    }, error: function () {
//                        layer.msg('系统异常，请联系管理员处理!');
//                    }
//                });
//            });
        });
    </script>
</head>
<body>
<div class="layui-content-body">
    <div class="scroll-box">
        <div class="breadcrumb-box">
              <span class="layui-breadcrumb" lay-separator="|">
   <a href="javascript:returnIndex2()">首页&nbsp;</a>
  <a href="">&nbsp;报表管理&nbsp;</a>
  <a href="">&nbsp;同比环比&nbsp;</a>
</span>
        </div>
        <div class="content-box ">
            <div class="form-select-box">
                <form class="layui-form layui-form-pane" action="">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">查询方式</label>
                            <div class="layui-inline">
                                <a href="sendCompareByCity.html" id="city"> <input type="radio" title="按地市" name="way" value="sendCompareByCity" checked=""></a>
                                <a href="sendCompareByCounty.html"> <input type="radio" title="按区县" name="way" value="sendCompareByCounty" ></a>
                                <a href="sendCompareByMgr.html"> <input type="radio" title="按项目" name="way" value="sendCompareByMgr" ></a>
                                <button class="layui-btn layui-btn-normal" type="button" id="download">
                                    导出
                                </button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
            <div class="table-box">
                <table class="layui-table" id="table">
                </table>
            </div>
        </div>
    </div>
</div>
</body>
</html>